/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package classPack;

import java.net.InetAddress;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 *
 * @author Eu
 */
public class Chave {

    public static String getChave() {
        String ipCliente = null;
        String data = null;
        try {
            DateFormat dateFormat = new SimpleDateFormat("yyyy_MM_dd");
            Date date = new Date();
            ipCliente = getIpLocal();
            data = dateFormat.format(date);
            return ipCliente + "_" + data;

        } catch (Exception e) {
        }
        return null;
    }

    public static String getChave(String ipCliente) {
        String data = null;
        DateFormat dateFormat = new SimpleDateFormat("yyyy_MM_dd");
        Date date = new Date();
        data = dateFormat.format(date);
        System.out.println("Com Ip: " + ipCliente + "_" + data);
        return ipCliente + "_" + data;
    }

    public static String getChaveLocal() {
        return "*" + System.getProperty("user.name") + "8";
    }

    public static String getIpLocal() {
        String ipCliente = null;
        try {
            InetAddress IP = InetAddress.getLocalHost();
            ipCliente = IP.getHostAddress();
            return ipCliente;
        } catch (Exception e) {
        }
        return null;
    }
}
